#ifndef __M_LOG_HPP__
#define __M_LOG_HPP__

#include <iostream>
#include <cstring>
#include <cstdio>
#include <ctime>

#define INF 0
#define DBG 1
#define ERR 2
#define DEFAULT_LOG_LEVEL INF

#define LOG(level,format,...) do{\
    if(DEFAULT_LOG_LEVEL>level) break;\
    time_t tm=time(nullptr);\
    struct tm* lt=localtime(&tm);\
    char stm[32];\
    bzero(stm,sizeof(stm));\
    strftime(stm,sizeof(stm)-1,"%H:%M:%S",lt);\
    fprintf(stdout,"[%s %s:%d]" format "\n",stm,__FILE__,__LINE__,##__VA_ARGS__);\
}while(0)

#define ILOG(format,...) LOG(INF,format,##__VA_ARGS__)
#define DLOG(format,...) LOG(DBG,format,##__VA_ARGS__)
#define ELOG(format,...) LOG(ERR,format,##__VA_ARGS__)

#endif